package com.zhisheng.orderItem.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.zhisheng.products.entity.Products;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * (OrderItems)表实体类
 *
 * @author 全哥
 * @since 2025-02-22 10:23:37
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class OrderItems extends Model<OrderItems> {

    @TableId
    private Integer id;

    private Long orderId;

    private Integer productId;

    private Integer quantity;

    private Double unitPrice;

    @TableLogic
    private Integer isDel;

    // 由于订单需要商品相关的信息,因此需要设计一个商品对象的成员变量,且这个变量不需要保存到数据库重视
    @TableField(exist = false)
    private Products product;

    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }
}

